'use strict';
const Controller = require('egg').Controller;

class CarController extends Controller {
  async index() {
    const { ctx } = this;
    ctx.body = 'hi, egg';
  }
  async addgoods() {
    const { ctx } = this;
    let reqobj = ctx.request.query
    reqobj.userid = ctx.cookies.get('userid')
    let data = await this.ctx.service.car.addgoods(reqobj)
    ctx.body = 'hi, egg';
  }
  async usercar() {
    const { ctx } = this;
    let userid = ctx.cookies.get('userid')
    let data = await this.ctx.service.car.usercar(userid)
    ctx.body = data;
  }
  async getParts() {
    const { ctx } = this;
    let data = await this.ctx.service.car.getParts()
    ctx.body = data;
  }
  async deletGoodscar() {
    const { ctx } = this;
    let userid = ctx.cookies.get('userid')
    let goods_id = ctx.request.query.goods_id
    let data = await this.ctx.service.car.deletGoodscar(goods_id, userid)
    ctx.body = '删除成功';
  }
  async serchGoods() {
    const { ctx } = this;
    let goods_name = ctx.request.query.goods_name
    let data = await this.ctx.service.car.serchGoods(goods_name)
    ctx.body = data;
  }
  async getCake() {
    const { ctx } = this;
    let data = await this.ctx.service.car.getCake()
    ctx.body = data;
  }
  async getnowGoods() {
    const { ctx } = this;
    let id = ctx.request.query.goods_id
    let data = await this.ctx.service.car.getnowGoods(id)
    ctx.body = data;
  }
  async addAddress() {
    const { ctx } = this;
    // console.log(2222222222222222);
    // let id=ctx.request.query.goods_id
    let id = ctx.cookies.get('userid')
    let obj = ctx.request.query.obj
    let data = await this.ctx.service.car.addAddress(id, JSON.parse(obj))
    ctx.body = 'data';
  }



}

module.exports = CarController;
